﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using XT.Exam.MODEL;
using Newtonsoft.Json;
using XT.Exam.IBLL;
using XT.Exam.IDataAccess;
using XT.Exam.BLL;
using System.Data.SqlClient;
namespace ExamSystemMvc.Controllers
{
    public class StudentController : Controller
    {
        //
        // GET: /Student/
        public ActionResult Index()
        {
            return View();
        }

        #region ///个人信息
        public string II()
        {
            var student = Session["student"] as Student;
            var str = JsonConvert.SerializeObject(student);
            return str;
        }
        #endregion
        public ActionResult Welcome()
        {
            return View();
        }

        public ActionResult UpdatePwd()
        {
            return View();
        }
        public ActionResult Start()
        {
            ITestPaperBuisnessLogic itp = new TestPaperBuisnessLogic();
            var student = Session["student"] as Student;
            ISToPhaseBuisnessLogic ist = new SToPhaseBuisnessLogic();
            var id = ist.GetStudentToPList(student.ID).FirstOrDefault().PhaseID;
            SqlParameter[] parameter ={
                                          new SqlParameter("@PhaseID",id),
                                          new SqlParameter("@TestPaper_State","true"),
                                      };

            return View(itp.GetList<TestPaper>(parameter));
        }
        public ActionResult BeginExam(Guid ID)
        {
            IExaminationPaperBusinessLogic iexam = new ExaminationPaperBusinessLogic();
            SqlParameter[] parameter ={
                                          new SqlParameter("@TestPaperID",ID),
                                      };
            ITestOptionsTableBuisnessLogic itest = new TestOptionsTableBuisnessLogic();
            
            ViewBag.Options= itest.GetListOrder<TestOptionsTable>();
            ViewBag.Exam = iexam.GetListOrder<ExaminationPaper>(parameter);
            return View();
        }    }
}
